package engine;

import java.util.*;


public class Vertex {
	
	/*@invariant pos != null;
	 *@invariant edges != null;
	 */
	private /*@ spec_public @*/ Vector pos;
	private /*@ spec_public @*/ List<Edge> edges;
	/**
	 * Vertex Constructor
	 * @param pos the position of the Vertex in XY space
	 * @param velo the velocity of the Vertex in XY terms
	 */
	/*
	 * @requires pos != null;
	 * @assignable this.pos, this.velo;
	 * @ensures this.pos == pos;
	 * @ensures edges != null;
	 */
	public Vertex(Vector pos) {
		if(pos==null){System.out.println("Illegal Input, cannot have null position");return;}
		this.pos = pos;
		edges = new LinkedList<Edge>();
	}
	/**
	 * getPos returns the position of the vertex as a 2-D vector
	 * @return the Vertex's position
	 */
	/*
	 * @requires pos != null;
	 * @ensures \result == this.pos;
	 */
	public Vector getPos() {
		return pos;
	}
	/**
	 * setPos sets the position of the Vertex
	 * @param pos the new position of the Vertex
	 */
	/*
	 * @requires pos != null;
	 * @ensures pos == this.pos;
	 * @assignable this.pos;
	 */
	public void setPos(Vector pos) {
		if(pos==null){System.out.println("Illegal Input, cannot have null position");return;}
		this.pos = pos;
	}
	/**
	 * getEdges returns the list of edges connected to the Vertex
	 * @return the edges connected to the Vertex
	 */
	/*
	 * @requires edges != null;
	 * @ensures \result == this.edges;
	 */
	public List<Edge> getEdges() {
		return edges;
	}
	/**
	 * setEdges sets the list of edges attached to the Vertex
	 * @param edges the List of Edges the vertex will believe it is attached to
	 */
	/*
	 * @requires edges != null;
	 * @ensures edges == this.edges;
	 * @assignable this.edges;
	 */
	public void setEdges(List<Edge> edges) {
		if(edges==null){System.out.println("Illegal Input, cannot have null edge list");return;}
		this.edges = edges;
	}
	/**
	 * addEdge adds an Edge to the Vertex's list of Edges
	 * @param e the Edge to add
	 */
	/*
	 * @requires e != null;
	 * @ensures edges.size() > \old(edges.size());
	 */
	public void addEdge(Edge e) {
		if(e==null){System.out.println("Illegal Input, cannot have null edge");return;}
		edges.add(e);
	}
	
	public String toString() {
		return pos.toString();
	}
}
